from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from options import options

url = r'http://192.168.190.130/upload/'
dr = webdriver.Chrome(options=options)
dr.get(url)
dr.maximize_window()
#登录
dr.find_element(By.XPATH, '//*[@id="ls_username"]').send_keys('test01')
dr.find_element(By.XPATH, '//*[@id="ls_password"]').send_keys('123456')
dr.find_element(By.XPATH, '//*[@id="lsform"]/div/div/table/tbody/tr[2]/td[3]/button').click()
sleep(6)

#发帖
dr.find_element(By.XPATH,'//*[@id="category_1"]/table/tbody/tr[1]/td[2]/h2/a').click()
sleep(2)
dr.find_element(By.XPATH,'//*[@id="newspecial"]').click()
sleep(1)
dr.find_element(By.XPATH,'//*[@id="subject"]').send_keys('元旦快乐！')
#切换到iframe里面
dr.switch_to.frame('e_iframe')
dr.find_element(By.XPATH, '/html/body').clear()
dr.find_element(By.XPATH,'/html/body').send_keys('元旦快乐元旦快乐元旦快乐元旦快乐元旦快乐')
sleep(2)
# dr.switch_to.default_content()  #跳回默认页面
dr.switch_to.parent_frame()
dr.find_element(By.XPATH,'//*[@id="postsubmit"]').click()
sleep(2)
dr.quit()